package com.kj.xuyuan.adapter;

import android.view.View;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.kj.xuyuan.R;
import com.kj.xuyuan.base.MyApp;
import com.kj.xuyuan.util.GlideUtils;
import com.luck.picture.lib.entity.LocalMedia;

public class SelectImageAdapter extends BaseQuickAdapter<LocalMedia, BaseViewHolder> {

    public SelectImageAdapter() {
        super(R.layout.item_image);
    }

    @Override
    protected void convert(BaseViewHolder helper, LocalMedia item) {
        ImageView ivImage = helper.getView(R.id.iv_image);
        ImageView ivDelete = helper.getView(R.id.iv_close);
        if(item.getBucketId() == -1){
            ivDelete.setVisibility(View.GONE);
            ivImage.setImageResource(R.mipmap.dynamic_add_picture);
        }else{
            GlideUtils.loadImage(mContext, MyApp.selectPhotoShow(mContext,item),ivImage);
            ivDelete.setVisibility(View.VISIBLE);
        }

        helper.addOnClickListener(R.id.iv_close);
        helper.addOnClickListener(R.id.iv_image);
    }
}
